﻿using Abp.Runtime.Validation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.WizardAgent
{
    /// <summary>
    /// 获取车组信息的Wizard请求信息类（单个）
    /// </summary>
    public class CarGroupRequest : CarGroupsRequest
    {
        /// <summary>
        /// 预订车组的唯一码
        /// </summary>
        public string SIPPCode { get; set; }

        public override string GetCacheKey()
        {
            return string.Empty;
        }

        public override string ToRequestXml()
        {
            var request = this;
            string xmlRequest = string.Format(WizardConsts.OTA_VehAvailRateRQ_One
                    , request.PickupDateTime
                    , request.ReturnDateTime
                    , request.PickUpStoreCode
                    , request.ReturnStoreCode
                    , ""
                    , request.XMembershipID
                    , request.XCorpDiscountNmbr
                    , request.XIATAANN
                    , request.SIPPCode
                )
                .Replace("'", "\"")
                .Replace("OutboundUser", WizardConsts.OutboundUser)
                .Replace("OutboundPwd", WizardConsts.OutboundPwd)
                .Replace("OutboundRequestID", WizardConsts.OutboundRequestID);

            return xmlRequest;
        }

        public override bool CheckRequest()
        {
            if (string.IsNullOrWhiteSpace(SIPPCode))
            {
                throw new WizardException("预订车组的唯一码不能为空！");
            }

            if (string.IsNullOrWhiteSpace(RateCode))
            {
                throw new WizardException("套餐价格代码不能为空！");
            }

            base.CheckRequest();

            return true;
        }
    }
}
